/*************************************************
Author: byron
Date: 05/17/2013
Description:
Notes: 
*************************************************/

#ifndef __CRoleAttrCfg_h__
#define __CRoleAttrCfg_h__

#include "CTArray.h"
#include "commclass.h"

class CRoleAttrCfgData
{
public:
    CRoleAttrCfgData() 
    {
        Clear();
    }

    void Clear()
    {
        _iID = 0;
        _iLevelUnit = 0;
        _iHP = 0;
        _iPhyAtk = 0;
        _iPhyDef = 0;
        _iMagAtk = 0;
        _iMagDef = 0;
        _iHit = 0;
        _iDodge = 0;
        _iDouble = 0;
        _iAntiDouble = 0;
        _iBlock = 0;
        _iAntiBlock = 0;
        _iOrder = 0;
        _iCrit = 0;
        _iImmuneInjury = 0;
        _iReactInjury = 0;
        _iPenetrate = 0;
        _iTreatment = 0;
        _iFightBack = 0;
        _iActAnger = 0;
    }

    bool IsNonNegativeData()
    {
        if (_iID <= 0 ||
            _iLevelUnit < 0 ||
            _iHP < 0 ||
            _iPhyAtk < 0 ||
            _iPhyDef < 0 ||
            _iMagAtk < 0 ||
            _iMagDef < 0 ||
            _iHit < 0 ||
            _iDodge < 0 ||
            _iDouble < 0 ||
            _iAntiDouble < 0 ||
            _iBlock < 0 ||
            _iAntiBlock < 0 ||
            _iOrder < 0 ||
            _iCrit < 0 ||
            _iImmuneInjury < 0 ||
            _iReactInjury < 0 ||
            _iPenetrate < 0 ||
            _iTreatment < 0 ||
            _iFightBack < 0 ||
            _iActAnger < 0)
        {
            return false;
        }
        
        return true;
    }

    virtual ~CRoleAttrCfgData() 
    {
    }

    int GetID() const {return _iID;}
    int GetLevelUnit() const {return _iLevelUnit;}
    int GetHP() const {return _iHP;}
    int GetPhyAtk() const {return _iPhyAtk;}
    int GetPhyDef() const {return _iPhyDef;}
    int GetMagAtk() const {return _iMagAtk;}
    int GetMagDef() const {return _iMagDef;}
    int GetHit() const {return _iHit;}
    int GetDodge() const {return _iDodge;}
    int GetDouble() const {return _iDouble;}
    int GetAntiDouble() const {return _iAntiDouble;}
    int GetBlock() const {return _iBlock;}
    int GetAntiBlock() const {return _iAntiBlock;}
    int GetOrder() const {return _iOrder;}
    int GetCrit() const {return _iCrit;}
    int GetImmuneInjury() const {return _iImmuneInjury;}
    int GetReactInjury() const {return _iReactInjury;}
    int GetPenetrate() const {return _iPenetrate;}
    int GetTreatment() const {return _iTreatment;}
    int GetFightBack() const {return _iFightBack;}
    int GetActAnger() const {return _iActAnger;}

    void SetID(int iID){_iID = iID;}
    void SetLevelUnit(int iLevelUnit){_iLevelUnit = iLevelUnit;}
    void SetHP(int iHP){_iHP = iHP;}
    void SetPhyAtk(int iPhyAtk){_iPhyAtk = iPhyAtk;}
    void SetPhyDef(int iPhyDef){_iPhyDef = iPhyDef;}
    void SetMagAtk(int iMagAtk){_iMagAtk = iMagAtk;}
    void SetMagDef(int iMagDef){_iMagDef = iMagDef;}
    void SetHit(int iHit){_iHit = iHit;}
    void SetDodge(int iDodge){_iDodge = iDodge;}
    void SetDouble(int iDouble){_iDouble = iDouble;}
    void SetAntiDouble(int iAntiDouble){_iAntiDouble = iAntiDouble;}
    void SetBlock(int iBlock){_iBlock = iBlock;}
    void SetAntiBlock(int iAntiBlock){_iAntiBlock = iAntiBlock;}
    void SetOrder(int iOrder){_iOrder = iOrder;}
    void SetCrit(int iCrit){_iCrit = iCrit;}
    void SetImmuneInjury(int iImmuneInjury){_iImmuneInjury = iImmuneInjury;}
    void SetReactInjury(int iReactInjury){_iReactInjury = iReactInjury;}
    void SetPenetrate(int iPenetrate){_iPenetrate = iPenetrate;}
    void SetTreatment(int iTreatment){_iTreatment = iTreatment;}
    void SetFightBack(int iFightBack){_iFightBack = iFightBack;}
    void SetActAnger(int iActAnger){_iActAnger = iActAnger;}

private:
    int         _iID;//配置ID = (职业*10) + 基础属性类型
    int         _iLevelUnit;//升级单位
    int         _iHP;//生命
    int         _iPhyAtk;//物攻
    int         _iPhyDef;//物防
    int         _iMagAtk;//魔攻
    int         _iMagDef;//魔防
    int         _iHit;//命中
    int         _iDodge;//闪避
    int         _iDouble;//暴击
    int         _iAntiDouble;//抗暴
    int         _iBlock;//格挡
    int         _iAntiBlock;//破击
    int         _iOrder;//出手速度
    int         _iCrit;//必杀
    int         _iImmuneInjury;//免伤
    int         _iReactInjury;//反伤
    int         _iPenetrate;//穿透
    int         _iTreatment;//痊愈
    int         _iFightBack;//反击
    int         _iActAnger;//出场怒气
};

class CRoleAttrCfg
{
public:
    CRoleAttrCfg() 
    {
        Clear();
    }

    void Clear()
    {
		_astRoleAttrCfg.m_iUsedCount = _astRoleAttrCfg.GetCount();
		for (int i = 0; i < _astRoleAttrCfg.Size(); ++i)
		{
			_astRoleAttrCfg[i].Clear();
		}
    }

    virtual ~CRoleAttrCfg() 
    {
    }

    int GetIndexByID(int iID);

    int AddConfig(CRoleAttrCfgData& stCfgData);

    int FindConfig(int iID);

    CRoleAttrCfgData& GetConfig(int iIndex);

private:
    CTLib::CTArray<CRoleAttrCfgData, CAREER_END * BASE_ATTR_MAX> _astRoleAttrCfg;
};

#endif // __CRoleAttrCfg_h__

